/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q1137.java
 * @Author : WangRuoyu
 * @Date 2023/1/12 16:25
 */

package leetcode;

public class Q1137 {
    public int tribonacci(int n) {
        if (n == 0) {
            return 0;
        } else if (n == 1 || n == 2) {
            return 1;
        }
        int[] f = new int[n + 1];
        f[0] = 0;
        f[1] = 1;
        f[2] = 1;
        for (int i = 3; i <= n; i++) {
            f[i] = f[i - 1] + f[i - 2] + f[i - 3];
        }
        return f[n];
    }

    public static void main(String[] args) {
        Q1137 sl = new Q1137();
        int n = 25;
        System.out.println(sl.tribonacci(n));
    }
}
